import Stack from "./lib/map_stack"

/**
 * @description 十进制转二进制
 * @param deNumber
 */


const decimalToBinaryStack = function(deNumber:number):string{
    let num = deNumber
    let rem
    let binaryString=''
    let stack=new Stack()
    console.time('二进制')

    while(num>0){
        // 取余
        rem=Math.floor(num%2)
        // 余数入栈
        stack.push(rem)
        // 重设num
        num=Math.floor(num/2)
    }
    // 一直出栈
    while(!stack.isEmpty()){
        binaryString += stack.pop().toString()
    }
    console.timeEnd('二进制')
    return binaryString
}

console.log(decimalToBinaryStack(4545454487744))